package eclipse;

import java.util.Arrays;
import java.util.Random;

public class ArrayExercise01 {
    public static void main(String[] args) {
        int[] a = new int[10];
        for(int i = 0; i < a.length; i++){
            a[i] = new Random().nextInt(100);
        }
        System.out.println(Arrays.toString(a));
        swap(a,3, 4);
        System.out.println(Arrays.toString(a));
        int index = min(a);
        System.out.println("最小值位置:" + index);
    }

    private static int min(int[] a) {
        int min = 0;
        for(int i = min + 1; i < a.length; i++){
            if(a[min] > a[i]){
                min = i;
            }
        }
        return min;
    }

    private static void swap(int[] arr, int a, int b) {
        int temp = arr[a];
        arr[a] = arr[b];
        arr[b] = temp;
    }


}
